package algorithm.shipinke;

/**
 * 腾讯笔试题
 * 计算ack(3,3)的值
 */

public class Tencent {

    int step = 0;

    public int ack(int m, int n) {
        // step++是我手动添加看运算步骤的
        step++;
        if (m == 0) return n+1;
        else if (n == 0) return ack(m-1, 1);
        else return ack(m - 1, ack(m, n - 1));
    }

    public static void main(String[] args) {
        Tencent tencent = new Tencent();
        System.out.println(tencent.ack(3, 3));
        System.out.println(tencent.step);
    }

}
